package com.net.common.dao;

import com.net.common.annotation.WriteTransactional;
import org.apache.ibatis.annotations.Param;
import org.springframework.transaction.annotation.Propagation;

import java.util.List;

/**
 * @author  on 2018.01.01
 * Mapper都是supports的事物属性
 */
public interface BasicMapper<K, T> {
    List<T> selectByCondition(@Param("condition") T condition, @Param("orderConditions") List<OrderCondition> orderConditions);

    T selectByPrimaryKey(K key);

    T selectOne(@Param("condition") T condition);

    long selectCount(@Param("condition") T condition);

    @WriteTransactional(propagation = Propagation.SUPPORTS)
    int insert(T record);

    @WriteTransactional(propagation = Propagation.SUPPORTS)
    int updateByPrimaryKey(T record);

    @WriteTransactional(propagation = Propagation.SUPPORTS)
    int deleteByPrimaryKey(K key);

    @WriteTransactional(propagation = Propagation.SUPPORTS)
    int deleteByCondition(@Param("condition") T condition);
}
